package org.lfs.operations;

import javax.swing.*;
import java.awt.*;
import java.net.URI;
import java.io.IOException;
import java.net.URISyntaxException;


public class AIAnalysis {

    public static void openAIAnalysis() {
        // 定义AI平台名称和对应网址的映射
        String[] aiOptions = {
                "DeepSeek", "Kimi", "文心一言", "通义千问", "讯飞星火", "豆包", "ChatGPT", "Claude"
        };

        String[] aiUrls = {
                "https://chat.deepseek.com/",
                "https://kimi.moonshot.cn/",
                "https://yiyan.baidu.com/",
                "https://tongyi.aliyun.com/",
                "https://xinghuo.xfyun.cn/",
                "https://www.doubao.com/chat/",
                "https://chatgpt.com/",
                "https://claude.ai/"
        };

        // 弹出选择对话框
        String selectedAI = (String) JOptionPane.showInputDialog(
                null,
                "请选择一个大模型进行分析",
                "AI分析",
                JOptionPane.PLAIN_MESSAGE,
                null,
                aiOptions,
                aiOptions[0] // 默认选项为第一个
        );

        // 用户选择了某个选项
        if (selectedAI != null) {
            int selectedIndex = -1;
            for (int i = 0; i < aiOptions.length; i++) {
                if (aiOptions[i].equals(selectedAI)) {
                    selectedIndex = i;
                    break;
                }
            }

            if (selectedIndex != -1) {
                browseToURL(aiUrls[selectedIndex]);
            }
        }
    }

    private static void browseToURL(String url) {
        try {
            Desktop.getDesktop().browse(new URI(url));
        } catch (IOException | URISyntaxException ex) {
            JOptionPane.showMessageDialog(null, "打开浏览器时发生错误: " + ex.getMessage());
        }
    }
}

